package practises;

public class Num2 {
    public static void main(String[] args) {
        ListNode head = new ListNode(1);
        head.next = new ListNode(2);
        head.next.next = new ListNode(3);
        int a = 1;
        Num2 n = new Num2();
        head = n.reverseList(head);
        int k = 1;
    }
    public ListNode reverseList(ListNode head) {
        ListNode cur = head;
        ListNode next = cur.next;
        head.next = null;
        ListNode n ;
        while(next != null) {
            n = next.next;
            next.next = cur;
            cur = next;
            next = n;
        }
        return cur;
    }
}
